package cn.green.core.scanner.store;

import cn.green.core.adapt.models.table.OrmTable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wang.yishu
 * @version 1.0
 * @className OrmTableStore
 * @description TODO
 * @date 2025/5/15 15:01
 */
public class OrmTableStore {
    private static final Map<String, OrmTable> ormTables = new HashMap<>();
    private static boolean isInit = false;
    public static void add(OrmTable ormTable) {
        ormTables.put(ormTable.getSourceName() + "_" + ormTable.getSchemeName()  + "_" + ormTable.getTableName(), ormTable);
    }

    public static OrmTable get(String sourceName, String schemeName, String tableName) {
        return ormTables.get(sourceName + "_" + schemeName + "_" + tableName);
    }

    public static List<OrmTable> all() {
        return new ArrayList<>(ormTables.values());
    }

    public static void hasInit() {
        if (!isInit) {
            isInit = true;
        }
    }

    public static boolean isInit() {
        return isInit;
    }
}
